/*
 *  POJ1159: Palindrome
 */

/*-------- Includes --------*/
#include <iostream>
#include <algorithm>

using namespace std;

/*-------- Defines --------*/


/*-------- Types --------*/


/*-------- Global Variables --------*/
int  N;
char cstr[5001];

int d[2][5001];

/*-------- Function Prototypes --------*/


/*-------- Main Function --------*/
int main(int argc, char const *argv[])
{
    cin >> N >> cstr;

    for (int i = 0; i <= N; i++) d[0][i] = 0;

    d[1][0] = 0;

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            int k = i % 2;
            int l = (i - 1) % 2;

            if (cstr[i - 1] == cstr[N - j])
                d[k][j] = d[l][j - 1] + 1;
            else
                d[k][j] = max(d[l][j], d[k][j - 1]);
        }
    }

    cout << N - d[N % 2][N] << endl;
}

/*-------- Functions --------*/

